<template>
    <div class="dialog">
        <a-modal
            v-drag-modal
            title="导入成果主要完成人"
            class="importIndex"
            :visible="visible"
            :confirm-loading="confirmLoading"
            @cancel="handleCancel"
            :maskClosable="false"

        >
            <template slot="footer">
                <a-button key="submit" type="primary" @click="handleOk">保存</a-button>
            </template>
            <div class="dialogCont">
                <div class="tableForm">
                    <a-table 
                        :columns="columns" 
                        :data-source="data" 
                        :row-selection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange, type: 'radio' }"
                        :pagination="false" 
                        align="center">
                    </a-table>
                </div>
            </div>
        </a-modal>
    </div>

</template>
<script>
const columns = [
    {
        title: '序号',
        dataIndex: 'wcr_xh',
        key: 'wcr_xh',
    },
    {
        title: '成果编号',
        dataIndex: 'cxj_xmbh',
        key: 'cxj_xmbh',
    },
    {
        title: '成果名称',
        key: 'cxj_mc_zw',
        dataIndex: 'cxj_mc_zw'
    },
    {
        title: '完成人姓名',
        key: 'wcr_xm',
        dataIndex: 'wcr_xm'
    }
];

const data = [];

import {
    cxjsbQueryWcrById
} from "@/api/shenbao"

export default {
    props: {
        flag: null
    },
    watch: {
        flag(next, prev) {
            if (next != prev) {
                var self = this;
                self.visible = !self.visible;
                self.getCxjsbQueryWcrById();
            }
        }
    },
    data() {
        return {
            visible: false,
            data,
            columns,
            selectedRowKeys: [],
            confirmLoading: false
        }
    },
    methods: {
        handleOk(e) {
            this.visible = false;
            console.log("人员id", this.data[this.selectedRowKeys].id)
            this.$emit('handleImport', this.data[this.selectedRowKeys].id)
        },
        handleCancel(e) {
            this.visible = false;
        },
        onSelectChange(selectedRowKeys) {
            this.selectedRowKeys = selectedRowKeys;
        },
        // 获取数据
        getCxjsbQueryWcrById(){
            cxjsbQueryWcrById().then(res=>{
                let data = res.data;
                if (data.success) {
                    console.log(data.result)
                    this.data = data.result;
                }
            })
        }
    }
}
</script>
<style lang="less" scoped>
    .ant-modal-content {
        width: 630px;
    }
    .tableForm {
        margin-top: 11px;
    }
</style>
